using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class PhysicianPriceGuarantorMap : EntityTypeConfiguration<PhysicianPriceGuarantor>
    {
        public PhysicianPriceGuarantorMap()
        {
            // Primary Key
            this.HasKey(t => new { t.invno, t.Doctor, t.Doctorid, t.amount, t.transid, t.Guar1Amount, t.Guar2Amount });

            // Properties
            this.Property(t => t.invno)
                .IsRequired()
                .HasMaxLength(8);

            this.Property(t => t.Doctor)
                .IsRequired()
                .HasMaxLength(35);

            this.Property(t => t.Doctorid)
                .IsRequired()
                .HasMaxLength(6);

            this.Property(t => t.transid)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            // Table & Column Mappings
            this.ToTable("PhysicianPriceGuarantor");
            this.Property(t => t.invno).HasColumnName("invno");
            this.Property(t => t.Doctor).HasColumnName("Doctor");
            this.Property(t => t.Doctorid).HasColumnName("Doctorid");
            this.Property(t => t.amount).HasColumnName("amount");
            this.Property(t => t.transid).HasColumnName("transid");
            this.Property(t => t.Guarantor1_Physicianprice).HasColumnName("Guarantor1_Physicianprice");
            this.Property(t => t.Guarantor2_Physicianprice).HasColumnName("Guarantor2_Physicianprice");
            this.Property(t => t.Guar1Amount).HasColumnName("Guar1Amount");
            this.Property(t => t.Guar2Amount).HasColumnName("Guar2Amount");
        }
    }
}
